package com.just.springbootmybatis.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.just.springbootmybatis.mapper.UserMapper;
import com.just.springbootmybatis.model.User;
import com.just.springbootmybatis.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    @Override
    public int addUser(User user) {
        return userMapper.insert(user);
    }

    @Override
    public List<User> findAllUser(int page, int size) {
        PageHelper.startPage(page,size);
        return userMapper.findAll();
    }

    @Override
    public Page<User> findAllUser2(int page, int size) {
        PageHelper.startPage(page,size);
        return userMapper.findAllByPage();
    }
}
